<template>
  <div class="app-container">
    <!-- 搜索 -->
    <el-card class="search-card">
      <el-form
        :model="queryParams"
        ref="queryForm"
        size="small"
        :inline="true"
        v-show="showSearch"
        class="formBox"
        label-width="68px"
      >
        <el-form-item label="姓名" prop="name">
          <el-input
            placeholder="请输入姓名"
            class="width_100"
            v-model="queryParams.name"
          />
        </el-form-item>
        <el-form-item label="身份证号" prop="idNumber">
          <el-input placeholder="请输入身份证号" v-model="queryParams.idNumber" />
        </el-form-item>
        <el-form-item label="状态" prop="status">
          <el-select
            v-model="queryParams.status"
            placeholder="请选择报名状态"
            @keyup.enter.native="handleQuery"
          >
            <el-option label="导入成功" value="1" />
            <el-option label="导入失败" value="2" />
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button
            type="primary"
            icon="el-icon-search"
            size="mini"
            @click="handleQuery"
          >
            搜索
          </el-button>
          <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
            >重置
          </el-button>
        </el-form-item>
      </el-form>
    </el-card>
    <!-- 列表 -->
    <el-card class="table-card" style="margin-top: 10px">
      <el-table :data="dataList" size="mini" stripe border>
        <el-table-column label="姓名" prop="name" />
        <el-table-column label="身份证号" prop="idNumber" />
        <el-table-column label="性别" prop="sex" />
        <el-table-column label="学院" prop="collegeName" />
        <el-table-column label="专业名称" prop="majorName" />
        <el-table-column label="模式" prop="education" />
        <el-table-column label="年级" prop="gradeName" />
        <el-table-column label="班级" prop="className" />
        <el-table-column label="学制" prop="schoolSystem" />
        <el-table-column label="报名时间" prop="signTime" width="140" />
        <el-table-column label="导入状态" prop="status">
          <template slot-scope="scope">
            <el-tag v-if="scope.row.status == '1'">导入成功</el-tag>
            <el-tag v-if="scope.row.status == '2'" type="danger">导入失败</el-tag>
          </template>
        </el-table-column>
        <el-table-column label="错误信息" prop="errorMessage">
          <template slot-scope="scope">
            <el-tooltip
              class="item"
              effect="dark"
              :content="scope.row.errorMessage"
              placement="bottom-start"
            >
              <div class="width_100 text-overflow">{{ scope.row.errorMessage }}</div>
            </el-tooltip>
          </template>
        </el-table-column>
        <el-table-column label="操作" width="120" fixed="right">
          <template slot-scope="scope">
            <el-button
              size="mini"
              type="text"
              @click="buttonMethod(1, scope.row)"
              v-hasPermi="['educational:mode:edit']"
              >删除
            </el-button>
          </template>
        </el-table-column>
      </el-table>
      <pagination
        v-show="total > 0"
        :total="total"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getList"
      />
    </el-card>
  </div>
</template>
<script>
import { systemDetailList, systemDetailDelete } from "@/api/studentManage";
export default {
  name: "",
  dicts: ["campus_status"],
  data() {
    return {
      batchId: "",
      status: false,
      list_status: false,
      title: "",
      dataList: [],
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        name: null,
        idNumber: null,
        status: null,
      },
      queryForm: {},
      total: 0,
      showSearch: true,
      date: [],
      list_status_index: "1",
    };
  },
  created() {
    this.batchId = this.$route.params.batchId;
    this.getList();
  },
  methods: {
    // 获取列表数据
    getList() {
      var data = this.queryParams;
      data.batchId = this.batchId;
      systemDetailList(data).then((res) => {
        if (res.code == 200) {
          this.dataList = res.rows;
          this.total = res.total;
        }
      });
    },
    /**
     * 按钮点击事件处理方法
     */
    buttonMethod(options, value) {
      //删除
      if (options == 1) {
        this.$confirm("确定删除" + value.name + "的信息吗？", "删除", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        })
          .then(() => {
            systemDetailDelete(value.id).then((res) => {
              if (res.code == 200) {
                this.$message({
                  type: "success",
                  message: res.msg,
                });
                this.getList();
              } else {
                this.$message({
                  type: "error",
                  message: res.msg,
                });
              }
            });
          })
          .catch(() => {});
      }
    },
    /**
     * 处理查询请求
     *
     * 将查询参数中的页码重置为1，并调用getList方法获取列表数据
     */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /**
     * 重置查询表单并重新执行查询操作
     */
    resetQuery() {
      this.queryParams = {
        pageNum: 1,
        pageSize: 10,
        name: null,
        idNumber: null,
        status: null,
      };
      this.resetForm("queryForm");
      this.handleQuery();
    },
    /**处理导出操作*/
    handleExport() {
      this.download(
        "agents/agents/export",
        {
          ...this.queryParams,
        },
        `学校校区管理.xlsx`
      );
    },
    handleSelectionChange(options) {
      this.roleIds = options.map((item) => item.id);
      console.log(this.roleIds, "options");
    },
    handleClick() {},
  },
};
</script>
